from flask import Flask
from flask_mail import Mail
from flask_cors import CORS
from controller.LoginController import login
from controller.PersonalController import personal
from controller.CommunityController import community
from controller.ViewController import view
from controller.RaceController import race
from config import Config
from dao import db

# 创建主app
app = Flask(__name__)
# 跨域
CORS(app, resources=r'/*')
# 绑定配置文件
app.config.from_object(Config)
# 邮箱配置文件
app.config["MAIL_SERVER"] = "smtp.qq.com"
app.config["MAIL_PORT"] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USE_TLS'] = False
app.config["MAIL_USERNAME"] = "jz147896325@qq.com"
app.config["MAIL_PASSWORD"] = "xypdvowfouzmdbdj"
mail = Mail(app)
# 绑定数据库
db.init_app(app)

# 注册蓝图到app
app.register_blueprint(login)
app.register_blueprint(personal)
app.register_blueprint(community)
app.register_blueprint(view)
app.register_blueprint(race)


@app.route('/', methods=['GET'])
def hello_world():
    return {'success': True}
